package com.guangzhi.weijianzhi.company.center;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.guangzhi.weijianzhi.R;
import com.guangzhi.weijianzhi.activity.BaseActivity;
import com.guangzhi.weijianzhi.http.HttpRequestUtils;
import com.loopj.android.http.AsyncHttpResponseHandler;
/**
 * 关于为兼职
 * @author Administrator
 *
 */
public class WJZActivity extends BaseActivity implements OnClickListener {

	private TextView jianyi;
	private TextView jiaru;
	private TextView weixin;
	private TextView qqqun;
	private TextView shangwu;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gz_guanyuweijianzhi);
		initView();
		initData();
	}
	private void initData() {
		// TODO Auto-generated method stub
         HttpRequestUtils.doHttpSettingItem( new AsyncHttpResponseHandler() {
			
			@Override
			public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
				// TODO Auto-generated method stub
				try {
					JSONObject jsonO = new JSONObject(new String(arg2));
					if(jsonO.optBoolean("status")){
						JSONArray jsonA = jsonO.optJSONArray("data");
						
						JSONObject optJSONObject = jsonA.optJSONObject(0);
						JSONObject optJSONObject2 = optJSONObject.optJSONObject("aboutWeiJobInfo");
						shangwu.setText(optJSONObject2.optString("business_ooperation"));
						jianyi.setText(optJSONObject2.optString("proposal"));
						jiaru.setText(optJSONObject2.optString("join_us"));
						weixin.setText("官方微信:"+optJSONObject2.optString("weixin"));
						qqqun.setText("官方QQ群:"+optJSONObject2.optString("qq"));
					}
					
				} catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			@Override
			public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	private void initView() {
		initTitle();
		titleTextV.setText("关于微兼职");
		TextView version = (TextView) findViewById(R.id.version);
		goBack.setOnClickListener(this);
		try {
			version.setText("微兼职"+getVersionName());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		shangwu = (TextView) findViewById(R.id.shangwu);
		jianyi = (TextView) findViewById(R.id.jianyi);
		jiaru = (TextView) findViewById(R.id.jiaru);
		weixin = (TextView) findViewById(R.id.weixin);
		qqqun = (TextView) findViewById(R.id.qqqun);
		
	}
	private String getVersionName() throws Exception
	   {
	           // 获取packagemanager的实例
	           PackageManager packageManager = getPackageManager();
	           // getPackageName()是你当前类的包名，0代表是获取版本信息
	           PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0);
	           String version = packInfo.versionName;
	           return version;
	   }
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		onBackPressed();
	}
	 
}
